class Solution:
    def minOperations(self, s: str) -> int:
        ans1 = 0
        last = "0"
        for ch in s:
            if ch != last:
                ans1 += 1
            last = "1" if last == "0" else "0"

        ans2 = 0
        last = "1"
        for ch in s:
            if ch != last:
                ans2 += 1
            last = "1" if last == "0" else "0"

        return min(ans1, ans2)


if __name__ == "__main__":
    print(Solution().minOperations("0100"))  # 1
    print(Solution().minOperations("10"))  # 0
    print(Solution().minOperations("1111"))  # 2
